﻿using AutofacProject.Entity;
using AutofacProject.Models.ViewModels;
using AutofacProject.Service;
using AutofacProject.Service.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AutofacProject.Controllers
{
    public class StudentController : Controller
    {
        private readonly IStudentService _studentService;
        private readonly AutofacDbContext _db;

        // GET: Student
        public StudentController(IStudentService studentService,AutofacDbContext db) {
            _studentService= studentService;
            _db = db;
        }
        public ActionResult Index()
        {
            //List<StudentVM> studentList = _studentService.GetList().Join(_db.Classes, s => s.class_id, c => c.id, (s, c) => new StudentVM
            //{
            //    id = s.id,
            //    name = s.name,
            //    class_id = s.class_id,
            //    class_name = c.class_name
            //}).ToList();
            List<Student> studentList = _studentService.GetList().ToList();
            return View(studentList);
        }
    }
}